
    import { createSlice } from "@reduxjs/toolkit";

 const countSlice=createSlice({

    name:"counter",

    initialState:{
        count:0
    },
    reducers:{

        addcount:(state,action)=>{
            console.log("action",action)
                state.count+=action.payload
        }
    }


 })
//  console.log('countSlice',countSlice)
 
 export  const {addcount}=countSlice.actions

 console.log('addcountxx',countSlice.actions.addcount(2))
 export const asyncAdd=(n)=>(dispatch)=>{
    setTimeout(() => {
       
        dispatch(addcount(n))
        console.log('dispatch999',dispatch)
    }, 2000);
 }

export default countSlice.reducer